﻿using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Text;

namespace Cms.Core.Infrastructure.Cache
{
    public class CustomMemoryCache : ICacheBase
    {
        private readonly IMemoryCache _memoryCache;
        public CustomMemoryCache(IMemoryCache memoryCache)
        {
            _memoryCache = memoryCache;
        }
        public T Get<T>(string key) where T : class, new() => _memoryCache.Get<T>(key);

        public object Get(object key) => _memoryCache.Get(key);

        public bool IsExist(string key)
        {
            var value=  _memoryCache.Get(key);
            return value == null ? false : true;
        }

        public void Remove(object key)
        {
            _memoryCache.Remove(key);
        }

        public void Set<T>(string key, T t) where T : class, new()
        {
            _memoryCache.Set<T>(key, t);
        }
    }
}
